package com.zyz.G_常用类.字符串.practice;

/**
 * @author: vick
 * @Date: 2025/3/19
 * @Description:
 * @version: 1.0
 */
public class PalindromeCheck {
    public static void main(String[] args) {
        String str = "madam";
        System.out.println(PalindromeCheck.isPalindrome(str));
    }

    /*public static boolean isPalindrome(String str) {
        String string = new StringBuilder(str).reverse().toString();
        return str.equals(string);
    }*/

    public static boolean isPalindrome(String str) {
        int left = 0;
        int right = str.length() - 1;
        while (left < right) {
            if (str.charAt(left) != str.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
